package peerToPeerFacebook.proj;



import java.io.IOException;

public interface IServerFileIO
{
  public static final String CreateFileMethodName = "createFile";
  public static final String GetFileContentsMethodName = "getFileContents";
  public static final String PutContentsToFileMethodName = "putContentsToFile";
  public static final String AppendContentsToFileMethodName = "appendContentsToFile";
  public static final String DeleteFileMethodName = "deleteFile";
  public static final String onServerRestartName = "onServerRestart";

  /**
   * Method that creates a new empty file and throws FileAlreadyExistException
   * if file is already there
   * 
   * @param filename the name of the file
   */
  public void createFile(String filename) throws IOException;

  /**
   * This method returns the contents of the file specified in a String
   * 
   * @param filename the file requested
   * @return contents of the file Or throws FileNotFoundException otherwise
   */
  public String getFileContents(String filename) throws IOException;

  /**
   * Method that writes the contents to the file mentioned
   * 
   * @param filename the file specified
   * @param contents the contents that needs to be written to the file
   */
  public void putContentsToFile(String filename, String contents) throws IOException;

  /**
   * Appends the contents to the end of the file, creates .temp file to ensure
   * if system restarts the file remains in the consistent state and its
   * contents are reverted back
   * 
   * @param filename the file mentioned
   * @param contents the contents that needs to be appended
   */
  public void appendContentsToFile(String filename, String contents) throws IOException;

  /**
   * This method deletes the requested file
   * 
   * @param filename the file which needs to be deleted
   * @return true if file gets deleted Or false if doesn't
   */
  public boolean deleteFile(String filename) throws IOException;
}
